home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gpp-1_42.lha / g++-1.42.0 / cplus-method.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  63KB  |  2,505 lines

  1. /* Handle the hair of processing (but not expanding) inline functions.
  2.    Also manage function and varaible name overloading.
  3.    Copyright (C) 1987 Free Software Foundation, Inc.
  4.    Contributed by Michael Tiemann (tiemann@mcc.com)
  5.  
  6.    This file is part of GNU CC.
  7.    
  8. GNU CC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 1, or (at your option)
  11. any later version.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with GNU CC; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22.  
  23. /* Handle method declarations.  */
  24. #include <stdio.h>
  25. #include "config.h"
  26. #include "tree.h"
  27. #include "cplus-tree.h"
  28. #include "assert.h"
  29.  
  30. /* TREE_LIST of the current inline functions that need to be
  31.    processed.  */
  32. struct pending_inline *pending_inlines;
  33.  
  34. # define MAX_INLINE_BUF_SIZE 8188
  35. # define OB_INIT() (inline_bufp = inline_buffer)
  36. # define OB_PUTC(C) (*inline_bufp++ = (C))
  37. # define OB_PUTC2(C1,C2) (OB_PUTC (C1), OB_PUTC (C2))
  38. # define OB_PUTS(S) (strcpy (inline_bufp, S), inline_bufp += sizeof (S) - 1)
  39. # define OB_PUTCP(S) (strcpy (inline_bufp, S), inline_bufp += strlen (S))
  40. # define OB_FINISH() (*inline_bufp++ = '\0')
  41.  
  42. /* Counter to help build parameter names in case they were omitted.  */
  43. static int dummy_name;
  44. static int in_parmlist;
  45. /* Just a pointer into INLINE_BUFFER.  */
  46. static char *inline_bufp;
  47. /* Also a pointer into INLINE_BUFFER.  This points to a safe place to
  48.    cut back to if we assign it 0, in case of error.  */
  49. static char *inline_errp;
  50. static char *inline_buffer;
  51. static void dump_type (), dump_decl ();
  52. static void dump_init (), dump_unary_op (), dump_binary_op ();
  53.  
  54. tree wrapper_name, wrapper_pred_name, anti_wrapper_name;
  55.  
  56. #ifdef NO_AUTO_OVERLOAD
  57. int is_overloaded ();
  58. #endif
  59.  
  60. void
  61. init_method ()
  62. {
  63.   char buf[sizeof (ANTI_WRAPPER_NAME_FORMAT) + 8];
  64.   sprintf (buf, WRAPPER_NAME_FORMAT, "");
  65.   wrapper_name = get_identifier (buf);
  66.   sprintf (buf, WRAPPER_PRED_NAME_FORMAT, "");
  67.   wrapper_pred_name = get_identifier (buf);
  68.   sprintf (buf, ANTI_WRAPPER_NAME_FORMAT, "");
  69.   anti_wrapper_name = get_identifier (buf);
  70. }
  71.  
  72. /* Return a pointer to the end of the new text in INLINE_BUFFER.
  73.    We cannot use `fatal' or `error' in here because that
  74.    might cause an infinite loop.  */
  75. static char *
  76. new_text_len (s)
  77.      char *s;
  78. {
  79.   while (*s++) ;
  80.  
  81.   if (s >= inline_buffer + MAX_INLINE_BUF_SIZE)
  82.     {
  83.       fprintf (stderr, "recompile c++ with larger MAX_INLINE_BUF_SIZE (%d)", MAX_INLINE_BUF_SIZE);
  84.       abort ();
  85.     }
  86.   return s - 1;
  87. }
  88.  
  89. /* Check that we have not overflowed INLINE_BUFFER.
  90.    We cannot use `fatal' or `error' in here because that
  91.    might cause an infinite loop.  */
  92. static void
  93. check_text_len (s)
  94.      char *s;
  95. {
  96.   if (s >= inline_buffer + MAX_INLINE_BUF_SIZE)
  97.     {
  98.       fprintf (stderr, "recompile c++ with larger MAX_INLINE_BUF_SIZE (%d)", MAX_INLINE_BUF_SIZE);
  99.       abort ();
  100.     }
  101. }
  102.  
  103. tree
  104. make_anon_parm_name ()
  105. {
  106.   char buf[32];
  107.  
  108.   sprintf (buf, ANON_PARMNAME_FORMAT, dummy_name++);
  109.   return get_identifier (buf);
  110. }
  111.  
  112. void
  113. clear_anon_parm_name ()
  114. {
  115.   /* recycle these names.  */
  116.   dummy_name = 0;
  117. }
  118.  
  119. static void
  120. dump_readonly_or_volatile (t)
  121.      tree t;
  122. {
  123.   if (TREE_READONLY (t))
  124.     OB_PUTS ("const ");
  125.   if (TREE_VOLATILE (t))
  126.     OB_PUTS ("volatile ");
  127. }
  128.  
  129. static void
  130. dump_type_prefix (t, p)
  131.      tree t;
  132.      int *p;
  133. {
  134.   int old_p = 0;
  135.   int print_struct = 1;
  136.   tree name;
  137.  
  138.   if (t == NULL_TREE)
  139.     return;
  140.  
  141.   switch (TREE_CODE (t))
  142.     {
  143.     case ERROR_MARK:
  144.       sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++);
  145.       break;
  146.  
  147.     case UNKNOWN_TYPE:
  148.       OB_PUTS ("<unknown type>");
  149.       return;
  150.  
  151.     case TREE_LIST:
  152.       dump_type (TREE_VALUE (t), &old_p);
  153.       if (TREE_CHAIN (t))
  154.     {
  155.       if (TREE_CHAIN (t) != void_list_node)
  156.         {
  157.           OB_PUTC (',');
  158.           dump_type (TREE_CHAIN (t), &old_p);
  159.         }
  160.     }
  161.       else OB_PUTS ("...");
  162.       return;
  163.  
  164.     case POINTER_TYPE:
  165.       *p += 1;
  166.       dump_type_prefix (TREE_TYPE (t), p);
  167.       while (*p)
  168.     {
  169.       OB_PUTC ('*');
  170.       *p -= 1;
  171.     }
  172.       if (TREE_READONLY (t))
  173.     OB_PUTS ("const ");
  174.       if (TREE_VOLATILE (t))
  175.     OB_PUTS ("volatile ");
  176.       return;
  177.  
  178.     case OFFSET_TYPE:
  179.       {
  180.     tree type = TREE_TYPE (t);
  181.     if (TREE_CODE (type) == FUNCTION_TYPE)
  182.       {
  183.         type = TREE_TYPE (type);
  184.         if (in_parmlist)
  185.           OB_PUTS ("auto ");
  186.       }
  187.  
  188.     dump_type_prefix (type, &old_p);
  189.  
  190.     OB_PUTC ('(');
  191.     dump_type (TYPE_OFFSET_BASETYPE (t), &old_p);
  192.     OB_PUTC2 (':', ':');
  193.     while (*p)
  194.       {
  195.         OB_PUTC ('*');
  196.         *p -= 1;
  197.       }
  198.     if (TREE_READONLY (t) | TREE_VOLATILE (t))
  199.       dump_readonly_or_volatile (t);
  200.     return;
  201.       }
  202.  
  203.     case METHOD_TYPE:
  204.       {
  205.     tree type = TREE_TYPE (t);
  206.     if (in_parmlist)
  207.       OB_PUTS ("auto ");
  208.  
  209.     dump_type_prefix (type, &old_p);
  210.  
  211.     OB_PUTC ('(');
  212.     dump_type (TYPE_METHOD_BASETYPE (t), &old_p);
  213.     OB_PUTC2 (':', ':');
  214.     while (*p)
  215.       {
  216.         OB_PUTC ('*');
  217.         *p -= 1;
  218.       }
  219.     if (TREE_READONLY (t) | TREE_VOLATILE (t))
  220.       dump_readonly_or_volatile (t);
  221.     return;
  222.       }
  223.  
  224.     case REFERENCE_TYPE:
  225.       dump_type_prefix (TREE_TYPE (t), p);
  226.       OB_PUTC ('&');
  227.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  228.     dump_readonly_or_volatile (t);
  229.       return;
  230.  
  231.     case ARRAY_TYPE:
  232.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  233.     dump_readonly_or_volatile (t);
  234.       dump_type_prefix (TREE_TYPE (t), p);
  235.       return;
  236.  
  237.     case FUNCTION_TYPE:
  238.       if (in_parmlist)
  239.     OB_PUTS ("auto ");
  240.       dump_type_prefix (TREE_TYPE (t), &old_p);
  241.       OB_PUTC ('(');
  242.       while (*p)
  243.     {
  244.       OB_PUTC ('*');
  245.       *p -= 1;
  246.     }
  247.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  248.     dump_readonly_or_volatile (t);
  249.       return;
  250.  
  251.     case IDENTIFIER_NODE:
  252.       sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t));
  253.       break;
  254.  
  255.     case RECORD_TYPE:
  256.       if (TREE_READONLY (t))
  257.     OB_PUTS ("const ");
  258.       if (TREE_VOLATILE (t))
  259.     OB_PUTS ("volatile ");
  260.       if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t))
  261.     print_struct = 0;
  262.       name = TYPE_NAME (t);
  263.       if (TREE_CODE (name) == TYPE_DECL)
  264.     name = DECL_NAME (name);
  265.       if (print_struct)
  266.     sprintf (inline_bufp, "struct %s ", IDENTIFIER_POINTER (name));
  267.       else
  268.     sprintf (inline_bufp, "class %s ", IDENTIFIER_POINTER (name));
  269.       break;
  270.  
  271.     case UNION_TYPE:
  272.       if (TREE_READONLY (t))
  273.     OB_PUTS ("const ");
  274.       if (TREE_VOLATILE (t))
  275.     OB_PUTS ("volatile ");
  276.       name = TYPE_NAME (t);
  277.       if (TREE_CODE (name) == TYPE_DECL)
  278.     name = DECL_NAME (name);
  279.       sprintf (inline_bufp, "union %s ", IDENTIFIER_POINTER (name));
  280.       break;
  281.  
  282.     case ENUMERAL_TYPE:
  283.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  284.     dump_readonly_or_volatile (t);
  285.       name = TYPE_NAME (t);
  286.       if (TREE_CODE (name) == TYPE_DECL)
  287.     name = DECL_NAME (name);
  288.       sprintf (inline_bufp, "enum %s ", IDENTIFIER_POINTER (name));
  289.       break;
  290.  
  291.     case TYPE_DECL:
  292.       if (TREE_READONLY (t))
  293.     OB_PUTS ("const ");
  294.       if (TREE_VOLATILE (t))
  295.     OB_PUTS ("volatile ");
  296.       sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t)));
  297.       break;
  298.  
  299.     case INTEGER_TYPE:
  300.       /* Normally, `unsigned' is part of the deal.  Not so if it comes
  301.      with `const' or `volatile'.  */
  302.       if (TREE_UNSIGNED (t)
  303.       && (TREE_READONLY (t) || TREE_VOLATILE (t)))
  304.     OB_PUTS ("unsigned ");
  305.       /* fall through.  */
  306.     case REAL_TYPE:
  307.     case VOID_TYPE:
  308.       if (TREE_READONLY (t))
  309.     OB_PUTS ("const ");
  310.       if (TREE_VOLATILE (t))
  311.     OB_PUTS ("volatile ");
  312.       sprintf (inline_bufp, "%s ", TYPE_NAME_STRING (t));
  313.       break;
  314.  
  315.     default:
  316.       abort ();
  317.     }
  318.   inline_bufp = new_text_len (inline_bufp);
  319. }
  320.  
  321. static void
  322. dump_type_suffix (t, p)
  323.      tree t;
  324.      int *p;
  325. {
  326.   int old_p = 0;
  327.  
  328.   if (t == NULL_TREE)
  329.     return;
  330.  
  331.   switch (TREE_CODE (t))
  332.     {
  333.     case ERROR_MARK:
  334.       sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++);
  335.       break;
  336.  
  337.     case UNKNOWN_TYPE:
  338.       return;
  339.  
  340.     case POINTER_TYPE:
  341.       dump_type_suffix (TREE_TYPE (t), p);
  342.       return;
  343.  
  344.     case OFFSET_TYPE:
  345.       {
  346.     tree type = TREE_TYPE (t);
  347.  
  348.     OB_PUTC (')');
  349.     if (TREE_CODE (type) == FUNCTION_TYPE)
  350.       {
  351. #if 0
  352.         tree next_arg = TREE_CHAIN (TYPE_ARG_TYPES (type));
  353.         OB_PUTC ('(');
  354.         if (next_arg)
  355.           {
  356.         if (next_arg != void_list_node)
  357.           {
  358.             in_parmlist++;
  359.             dump_type (next_arg, &old_p);
  360.             in_parmlist--;
  361.           }
  362.           }
  363.         else OB_PUTS ("...");
  364.         OB_PUTC (')');
  365.         dump_type_suffix (TREE_TYPE (type), p);
  366. #else
  367.         abort ();
  368. #endif
  369.       }
  370.     return;
  371.       }
  372.  
  373.     case METHOD_TYPE:
  374.       {
  375.     tree next_arg;
  376.     OB_PUTC (')');
  377.     next_arg = TREE_CHAIN (TYPE_ARG_TYPES (t));
  378.     OB_PUTC ('(');
  379.     if (next_arg)
  380.       {
  381.         if (next_arg != void_list_node)
  382.           {
  383.         in_parmlist++;
  384.         dump_type (next_arg, &old_p);
  385.         in_parmlist--;
  386.           }
  387.       }
  388.     else OB_PUTS ("...");
  389.     OB_PUTC (')');
  390.     dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
  391.     dump_type_suffix (TREE_TYPE (t), p);
  392.     return;
  393.       }
  394.  
  395.     case REFERENCE_TYPE:
  396.       dump_type_suffix (TREE_TYPE (t), p);
  397.       return;
  398.  
  399.     case ARRAY_TYPE:
  400.       dump_type_suffix (TREE_TYPE (t), p);
  401.       OB_PUTC2 ('[', ']');
  402.       return;
  403.  
  404.     case FUNCTION_TYPE:
  405.       OB_PUTC2 (')', '(');
  406.       if (TYPE_ARG_TYPES (t) && TYPE_ARG_TYPES (t) != void_list_node)
  407.     {
  408.       in_parmlist++;
  409.       dump_type (TYPE_ARG_TYPES (t), &old_p);
  410.       in_parmlist--;
  411.     }
  412.       OB_PUTC (')');
  413.       dump_type_suffix (TREE_TYPE (t), p);
  414.       return;
  415.  
  416.     case IDENTIFIER_NODE:
  417.     case RECORD_TYPE:
  418.     case UNION_TYPE:
  419.     case ENUMERAL_TYPE:
  420.     case TYPE_DECL:
  421.     case INTEGER_TYPE:
  422.     case REAL_TYPE:
  423.     case VOID_TYPE:
  424.       return;
  425.  
  426.     default:
  427.       abort ();
  428.     }
  429.   inline_bufp = new_text_len (inline_bufp);
  430. }
  431.  
  432. static void
  433. dump_type (t, p)
  434.      tree t;
  435.      int *p;
  436. {
  437.   int old_p = 0;
  438.   int print_struct = 1;
  439.  
  440.   if (t == NULL_TREE)
  441.     return;
  442.  
  443.   switch (TREE_CODE (t))
  444.     {
  445.     case ERROR_MARK:
  446.       sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++);
  447.       break;
  448.  
  449.     case UNKNOWN_TYPE:
  450.       OB_PUTS ("<unknown type>");
  451.       return;
  452.  
  453.     case TREE_LIST:
  454.       dump_type (TREE_VALUE (t), &old_p);
  455.       if (TREE_CHAIN (t))
  456.     {
  457.       if (TREE_CHAIN (t) != void_list_node)
  458.         {
  459.           OB_PUTC (',');
  460.           dump_type (TREE_CHAIN (t), &old_p);
  461.         }
  462.     }
  463.       else OB_PUTS ("...");
  464.       return;
  465.  
  466.     case POINTER_TYPE:
  467.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  468.     dump_readonly_or_volatile (t);
  469.       *p += 1;
  470.       dump_type (TREE_TYPE (t), p);
  471.       while (*p)
  472.     {
  473.       OB_PUTC ('*');
  474.       *p -= 1;
  475.     }
  476.       return;
  477.  
  478.     case REFERENCE_TYPE:
  479.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  480.     dump_readonly_or_volatile (t);
  481.       dump_type (TREE_TYPE (t), p);
  482.       OB_PUTC ('&');
  483.       return;
  484.  
  485.     case ARRAY_TYPE:
  486.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  487.     dump_readonly_or_volatile (t);
  488.       dump_type (TREE_TYPE (t), p);
  489.       OB_PUTC2 ('[', ']');
  490.       return;
  491.  
  492.     case OFFSET_TYPE:
  493.     case METHOD_TYPE:
  494.     case FUNCTION_TYPE:
  495.       dump_type_prefix (t, p);
  496.       dump_type_suffix (t, p);
  497.       return;
  498.  
  499.     case IDENTIFIER_NODE:
  500.       sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t));
  501.       break;
  502.  
  503.     case RECORD_TYPE:
  504.       {
  505.     if (TREE_READONLY (t) | TREE_VOLATILE (t))
  506.       dump_readonly_or_volatile (t);
  507.     if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t))
  508.       print_struct = 0;
  509.     t = TYPE_NAME (t);
  510.     if (TREE_CODE (t) == TYPE_DECL)
  511.       t = DECL_NAME (t);
  512.     if (print_struct)
  513.       sprintf (inline_bufp, "struct %s ", IDENTIFIER_POINTER (t));
  514.     else
  515.       sprintf (inline_bufp, "class %s ", IDENTIFIER_POINTER (t));
  516.     break;
  517.       }
  518.  
  519.     case UNION_TYPE:
  520.       {
  521.     if (TREE_READONLY (t) | TREE_VOLATILE (t))
  522.       dump_readonly_or_volatile (t);
  523.     t = TYPE_NAME (t);
  524.     if (TREE_CODE (t) == TYPE_DECL)
  525.       t = DECL_NAME (t);
  526.     sprintf (inline_bufp, "union %s ", IDENTIFIER_POINTER (t));
  527.       }
  528.       break;
  529.  
  530.     case ENUMERAL_TYPE:
  531.       {
  532.     if (TREE_READONLY (t) | TREE_VOLATILE (t))
  533.       dump_readonly_or_volatile (t);
  534.     t = TYPE_NAME (t);
  535.     if (TREE_CODE (t) == TYPE_DECL)
  536.       t = DECL_NAME (t);
  537.     sprintf (inline_bufp, "enum %s ", IDENTIFIER_POINTER (t));
  538.       }
  539.       break;
  540.  
  541.     case TYPE_DECL:
  542.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  543.     dump_readonly_or_volatile (t);
  544.       sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t)));
  545.       break;
  546.  
  547.     case INTEGER_TYPE:
  548.       /* Normally, `unsigned' is part of the deal.  Not so if it comes
  549.      with `const' or `volatile'.  */
  550.       if (TREE_READONLY (t) | TREE_VOLATILE (t))
  551.     dump_readonly_or_volatile (t);
  552.       if (TREE_UNSIGNED (t)
  553.       && (TREE_READONLY (t) | TREE_VOLATILE (t)))
  554.     OB_PUTS ("unsigned ");
  555.       /* fall through.  */
  556.     case REAL_TYPE:
  557.     case VOID_TYPE:
  558.       sprintf (inline_bufp, "%s ", TYPE_NAME_STRING (t));
  559.       break;
  560.  
  561.     default:
  562.       abort ();
  563.     }
  564.   inline_bufp = new_text_len (inline_bufp);
  565. }
  566.  
  567. static void
  568. dump_decl (t)
  569.      tree t;
  570. {
  571.   int p = 0;
  572.  
  573.   if (t == NULL_TREE)
  574.     return;
  575.  
  576.   switch (TREE_CODE (t))
  577.     {
  578.     case ERROR_MARK:
  579.       strcpy (inline_bufp, " /* decl error */ ");
  580.       break;
  581.  
  582.     case PARM_DECL:
  583.       dump_type_prefix (TREE_TYPE (t), &p);
  584.       if (DECL_NAME (t))
  585.     dump_decl (DECL_NAME (t));
  586.       else
  587.     {
  588.       sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++);
  589.       break;
  590.     }
  591.       dump_type_suffix (TREE_TYPE (t), &p);
  592.       return;
  593.  
  594.     case CALL_EXPR:
  595.       dump_decl (TREE_OPERAND (t, 0));
  596.       OB_PUTC ('(');
  597.       in_parmlist++;
  598.       dump_decl (TREE_OPERAND (t, 1));
  599.       in_parmlist--;
  600.       t = tree_last (TYPE_ARG_TYPES (TREE_TYPE (t)));
  601.       if (!t || t != void_list_node)
  602.     OB_PUTS ("...");
  603.       OB_PUTC (')');
  604.       return;
  605.  
  606.     case ARRAY_REF:
  607.       dump_decl (TREE_OPERAND (t, 0));
  608.       OB_PUTC ('[');
  609.       dump_decl (TREE_OPERAND (t, 1));
  610.       OB_PUTC (']');
  611.       return;
  612.  
  613.     case TYPE_DECL:
  614.       sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t)));
  615.       break;
  616.  
  617.     case TYPE_EXPR:
  618.       abort ();
  619.       break;
  620.  
  621.     case IDENTIFIER_NODE:
  622.       if (OPERATOR_NAME_P (t))
  623.     sprintf (inline_bufp, "operator %s ", operator_name_string (t));
  624.       else if (OPERATOR_TYPENAME_P (t))
  625.     {
  626.       OB_PUTS ("operator ");
  627.       dump_type (TREE_TYPE (t), &p);
  628.       return;
  629.     }
  630.       else
  631.     sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t));
  632.       break;
  633.  
  634.     case BIT_NOT_EXPR:
  635.       OB_PUTC2 ('~', ' ');
  636.       dump_decl (TREE_OPERAND (t, 0));
  637.       return;
  638.  
  639.     case SCOPE_REF:
  640.       sprintf (inline_bufp, "%s :: ", IDENTIFIER_POINTER (TREE_OPERAND (t, 0)));
  641.       inline_bufp += sizeof ("%s :: ") + IDENTIFIER_LENGTH (TREE_OPERAND (t, 0));
  642.       dump_decl (TREE_OPERAND (t, 1));
  643.       return;
  644.  
  645.     case INDIRECT_REF:
  646.       OB_PUTC ('*');
  647.       dump_decl (TREE_OPERAND (t, 0));
  648.       return;
  649.  
  650.     case ADDR_EXPR:
  651.       OB_PUTC ('&');
  652.       dump_decl (TREE_OPERAND (t, 0));
  653.       return;
  654.  
  655.     default:
  656.       abort ();
  657.     }
  658.   inline_bufp = new_text_len (inline_bufp);
  659. }
  660.  
  661. static void
  662. dump_init_list (l)
  663.      tree l;
  664. {
  665.   while (l)
  666.     {
  667.       dump_init (TREE_VALUE (l));
  668.       if (TREE_CHAIN (l))
  669.     OB_PUTC (',');
  670.       l = TREE_CHAIN (l);
  671.     }
  672. }
  673.  
  674. static void
  675. dump_init (t)
  676.      tree t;
  677. {
  678.   int dummy;
  679.  
  680.   switch (TREE_CODE (t))
  681.     {
  682.     case VAR_DECL:
  683.     case PARM_DECL:
  684.       sprintf (inline_bufp, " %s ", IDENTIFIER_POINTER (DECL_NAME (t)));
  685.       break;
  686.  
  687.     case FUNCTION_DECL:
  688.       {
  689.     tree name = DECL_NAME (t);
  690.  
  691.     if (DESTRUCTOR_NAME_P (name))
  692.       sprintf (inline_bufp, " ~%s ",
  693.            IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t)));
  694.     else if (OPERATOR_NAME_P (name))
  695.       sprintf (inline_bufp, "operator %s ", operator_name_string (name));
  696.     else if (OPERATOR_TYPENAME_P (name))
  697.       {
  698.         dummy = 0;
  699.         OB_PUTS ("operator ");
  700.         dump_type (TREE_TYPE (name), &dummy);
  701.       }
  702. #if 0
  703.     else if (WRAPPER_NAME_P (name))
  704.       sprintf (inline_bufp, " ()%s ",
  705.            IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t)));
  706.     else if (WRAPPER_PRED_NAME_P (name))
  707.       sprintf (inline_bufp, " ()?%s ",
  708.            IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t)));
  709.     else if (ANTI_WRAPPER_NAME_P (name))
  710.       sprintf (inline_bufp, " ~()%s ",
  711.            IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t)));
  712. #endif
  713.     else sprintf (inline_bufp, " %s ",
  714.               IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t)));
  715.       }
  716.       break;
  717.  
  718.     case CONST_DECL:
  719.       dummy = 0;
  720.       OB_PUTC2 ('(', '(');
  721.       dump_type (TREE_TYPE (t), &dummy);
  722.       OB_PUTC (')');
  723.       dump_init (DECL_INITIAL (t));
  724.       OB_PUTC (')');
  725.       return;
  726.  
  727.     case INTEGER_CST:
  728.       sprintf (inline_bufp, " %d ", TREE_INT_CST_LOW (t));
  729.       break;
  730.  
  731.     case REAL_CST:
  732.       sprintf (inline_bufp, " %g ", TREE_REAL_CST (t));
  733.       break;
  734.  
  735.     case STRING_CST:
  736.       {
  737.     char *p = TREE_STRING_POINTER (t);
  738.     int len = TREE_STRING_LENGTH (t) - 1;
  739.     int i;
  740.  
  741.     check_text_len (inline_bufp + len + 2);
  742.     OB_PUTC ('\"');
  743.     for (i = 0; i < len; i++)
  744.       {
  745.         register char c = p[i];
  746.         if (c == '\"' || c == '\\')
  747.           OB_PUTC ('\\');
  748.         if (c >= ' ' && c < 0177)
  749.           OB_PUTC (c);
  750.         else
  751.           {
  752.         sprintf (inline_bufp, "\\%03o", c);
  753.         inline_bufp = new_text_len (inline_bufp);
  754.           }
  755.       }
  756.     OB_PUTC ('\"');
  757.       }
  758.       return;
  759.  
  760.     case COMPOUND_EXPR:
  761.       dump_binary_op (",", t, 1);
  762.       break;
  763.  
  764.     case COND_EXPR:
  765.       OB_PUTC ('(');
  766.       dump_init (TREE_OPERAND (t, 0));
  767.       OB_PUTS (" ? ");
  768.       dump_init (TREE_OPERAND (t, 1));
  769.       OB_PUTS (" : ");
  770.       dump_init (TREE_OPERAND (t, 2));
  771.       OB_PUTC (')');
  772.       return;
  773.  
  774.     case SAVE_EXPR:
  775.       if (TREE_HAS_CONSTRUCTOR (t))
  776.     {
  777.       dummy = 0;
  778.       OB_PUTS ("new ");
  779.       dump_type (TREE_TYPE (TREE_TYPE (t)), &dummy);
  780.       PARM_DECL_EXPR (t) = 1;
  781.     }
  782.       else
  783.     {
  784.       sorry ("operand of SAVE_EXPR not understood");
  785.       *inline_errp = '\0';
  786.       inline_bufp = inline_errp + 1;
  787.     }
  788.       return;
  789.  
  790.     case NEW_EXPR:
  791.       strcpy (inline_bufp, TYPE_NAME_STRING (TREE_TYPE (t)));
  792.       inline_bufp = new_text_len (inline_bufp);
  793.       OB_PUTC ('(');
  794.       dump_init_list (TREE_CHAIN (TREE_OPERAND (t, 1)));
  795.       OB_PUTC (')');
  796.       return;
  797.  
  798.     case CALL_EXPR:
  799.       OB_PUTC ('(');
  800.       dump_init (TREE_OPERAND (t, 0));
  801.       dump_init_list (TREE_OPERAND (t, 1));
  802.       OB_PUTC (')');
  803.       return;
  804.  
  805.     case MODIFY_EXPR:
  806.     case PLUS_EXPR:
  807.     case MINUS_EXPR:
  808.     case MULT_EXPR:
  809.     case TRUNC_DIV_EXPR:
  810.     case TRUNC_MOD_EXPR:
  811.     case MIN_EXPR:
  812.     case MAX_EXPR:
  813.     case LSHIFT_EXPR:
  814.     case RSHIFT_EXPR:
  815.     case BIT_IOR_EXPR:
  816.     case BIT_XOR_EXPR:
  817.     case BIT_AND_EXPR:
  818.     case BIT_ANDTC_EXPR:
  819.     case TRUTH_ANDIF_EXPR:
  820.     case TRUTH_ORIF_EXPR:
  821.     case LT_EXPR:
  822.     case LE_EXPR:
  823.     case GT_EXPR:
  824.     case GE_EXPR:
  825.     case EQ_EXPR:
  826.     case NE_EXPR:
  827.       dump_binary_op (opname_tab[(int) TREE_CODE (t)], t,
  828.               strlen (opname_tab[(int) TREE_CODE (t)]));
  829.       return;
  830.  
  831.     case CEIL_DIV_EXPR:
  832.     case FLOOR_DIV_EXPR:
  833.     case ROUND_DIV_EXPR:
  834.       dump_binary_op ("/", t, 1);
  835.       return;
  836.  
  837.     case CEIL_MOD_EXPR:
  838.     case FLOOR_MOD_EXPR:
  839.     case ROUND_MOD_EXPR:
  840.       dump_binary_op ("%", t, 1);
  841.       return;
  842.  
  843.     case COMPONENT_REF:
  844.       dump_binary_op (".", t, 1);
  845.       return;
  846.  
  847.     case CONVERT_EXPR:
  848.       dump_unary_op ("+", t, 1);
  849.       return;
  850.  
  851.     case ADDR_EXPR:
  852.       if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
  853.       || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST)
  854.     dump_init (TREE_OPERAND (t, 0));
  855.       else
  856.     dump_unary_op ("&", t, 1);
  857.       return;
  858.  
  859.     case INDIRECT_REF:
  860.       dump_unary_op ("*", t, 1);
  861.       return;
  862.  
  863.     case NEGATE_EXPR:
  864.     case BIT_NOT_EXPR:
  865.     case TRUTH_NOT_EXPR:
  866.     case PREDECREMENT_EXPR:
  867.     case PREINCREMENT_EXPR:
  868.       dump_unary_op (opname_tab [(int)TREE_CODE (t)], t,
  869.              strlen (opname_tab[(int) TREE_CODE (t)]));
  870.       return;
  871.  
  872.     case POSTDECREMENT_EXPR:
  873.     case POSTINCREMENT_EXPR:
  874.       OB_PUTC ('(');
  875.       dump_init (TREE_OPERAND (t, 0));
  876.       OB_PUTCP (opname_tab[(int)TREE_CODE (t)]);
  877.       OB_PUTC (')');
  878.       return;
  879.  
  880.     case NOP_EXPR:
  881.       dummy = 0;
  882.       OB_PUTC2 ('(', '(');
  883.       dump_type (TREE_TYPE (t), &dummy);
  884.       OB_PUTC (')');
  885.       dump_init (TREE_OPERAND (t, 0));
  886.       OB_PUTC (')');
  887.       return;
  888.  
  889.     case CONSTRUCTOR:
  890.       OB_PUTC ('{');
  891.       dump_init_list (CONSTRUCTOR_ELTS (t));
  892.       OB_PUTC ('}');
  893.       return;
  894.  
  895.       /*  This list is incomplete, but should suffice for now.
  896.       It is very important that `sorry' does not call
  897.       `report_error_function'.  That could cause an infinite loop.  */
  898.     default:
  899.       sorry ("that operation not supported for default parameters");
  900.  
  901.       /* fall through to ERROR_MARK...  */
  902.     case ERROR_MARK:
  903.       *inline_errp = '\0';
  904.       inline_bufp = inline_errp + 1;
  905.       return;
  906.     }
  907.   inline_bufp = new_text_len (inline_bufp);
  908. }
  909.  
  910. static void
  911. dump_binary_op (opstring, t, len)
  912.      char *opstring;
  913.      tree t;
  914.      int len;
  915. {
  916.   OB_PUTC ('(');
  917.   dump_init (TREE_OPERAND (t, 0));
  918.   sprintf (inline_bufp, " %s ", opstring);
  919.   inline_bufp += len + 2;
  920.   dump_init (TREE_OPERAND (t, 1));
  921.   OB_PUTC (')');
  922.   check_text_len (inline_bufp);
  923. }
  924.  
  925. static void
  926. dump_unary_op (opstring, t, len)
  927.      char *opstring;
  928.      tree t;
  929.      int len;
  930. {
  931.   OB_PUTC ('(');
  932.   sprintf (inline_bufp, " %s ", opstring);
  933.   inline_bufp += len + 2;
  934.   dump_init (TREE_OPERAND (t, 0));
  935.   OB_PUTC (')');
  936.   check_text_len (inline_bufp);
  937. }
  938.  
  939. #ifdef DO_METHODS_THE_OLD_WAY
  940. /* Process the currently pending inline function definitions.
  941.    This entails:
  942.    (1) Creating a temporary file which contains return type,
  943.        delarator name, and argment names and types of the
  944.        function to be inlined.
  945.    (2) Reading that file into a buffer which can then be
  946.        made to look line another piece of inline code to
  947.        process, stuffing that on the top of the inline
  948.        stack, then letting the lexer and parser read from those
  949.        two.
  950. */
  951.  
  952. static struct pending_inline *
  953. stash_inline_prefix (cname, field)
  954.      tree cname, field;
  955. {
  956.   extern int lineno;
  957.   struct pending_inline *t;
  958.   tree name, fndecl, fntype;
  959.   int p = 0;
  960.   inline_buffer = (char *)alloca (MAX_INLINE_BUF_SIZE + 4);
  961.   dummy_name = 0;
  962.  
  963.   name = DECL_ORIGINAL_NAME (field);
  964.   /* We still don't do friends right.  */
  965.   fndecl = field;
  966.   fntype = TREE_TYPE (fndecl);
  967.  
  968.   if (TREE_INLINE (fndecl))
  969.     strcpy (inline_buffer, "inline ");
  970.   else
  971.     strcpy (inline_buffer, "static ");
  972.   inline_bufp = inline_buffer + strlen (inline_buffer);
  973.   if (! OPERATOR_TYPENAME_P (name))
  974.     dump_type_prefix (TREE_TYPE (fntype), &p);
  975.   if (TREE_CODE (fntype) == METHOD_TYPE)
  976.     {
  977.       dump_type (cname, &p);
  978.       inline_bufp[-1] = ':';
  979.       *inline_bufp++ = ':';
  980.       if (DESTRUCTOR_NAME_P (DECL_NAME (fndecl)))
  981.     OB_PUTC ('~');
  982. #if 0
  983.       else if (WRAPPER_NAME_P (DECL_NAME (fndecl)))
  984.     OB_PUTC2 ('(', ')');
  985.       else if (WRAPPER_PRED_NAME_P (DECL_NAME (fndecl)))
  986.     OB_PUTS ("()?");
  987.       else if (ANTI_WRAPPER_NAME_P (DECL_NAME (fndecl)))
  988.     OB_PUTS ("~()");
  989. #endif
  990.     }
  991.   dump_decl (name);
  992.   OB_PUTC ('(');
  993.   if (! DESTRUCTOR_NAME_P (DECL_NAME (fndecl)))
  994.     {
  995.       tree parmlist = DECL_ARGUMENTS (fndecl);
  996.       tree typelist = TYPE_ARG_TYPES (fntype);
  997.  
  998.       if (TREE_CODE (field) == FIELD_DECL)
  999.     {
  1000.       parmlist = TREE_CHAIN (parmlist);
  1001.       typelist = TREE_CHAIN (typelist);
  1002.     }
  1003.  
  1004.       in_parmlist++;
  1005.       while (parmlist)
  1006.     {
  1007.       dump_decl (parmlist);
  1008. #if 0
  1009.       if (TREE_PURPOSE (typelist))
  1010.         {
  1011.           inline_errp = inline_bufp;
  1012.           OB_PUTS (" = (");
  1013.           dump_init (TREE_PURPOSE (typelist));
  1014.           OB_PUTC (')');
  1015.           if (*inline_errp == '\0')
  1016.         inline_bufp = inline_errp;
  1017.         }
  1018. #endif
  1019.       if (TREE_CHAIN (parmlist))
  1020.         OB_PUTC (',');
  1021.       parmlist = TREE_CHAIN (parmlist);
  1022.       typelist = TREE_CHAIN (typelist);
  1023.     }
  1024.       in_parmlist--;
  1025.       if (!typelist || typelist != void_list_node)
  1026.     OB_PUTS ("...");
  1027.     }
  1028.   OB_PUTC (')');
  1029.  
  1030.   if (! OPERATOR_TYPENAME_P (name))
  1031.     dump_type_suffix (TREE_TYPE (fntype), &p);
  1032.   if (TREE_CODE (fntype) == METHOD_TYPE)
  1033.     dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))));
  1034.   {
  1035.     extern tree value_identifier;
  1036.  
  1037.     if (DECL_RESULT (fndecl) != value_identifier)
  1038.       {
  1039.     tree result = DECL_RESULT (fndecl);
  1040.  
  1041.     OB_PUTS ("return ");
  1042.     OB_PUTS (IDENTIFIER_POINTER (DECL_NAME (result)));
  1043.     if (DECL_INITIAL (result))
  1044.       {
  1045.         OB_PUTC ('=');
  1046.         dump_init (DECL_INITIAL (result));
  1047.         OB_PUTC (';');
  1048.       }
  1049.       }
  1050.   }
  1051.   OB_FINISH ();
  1052.   check_text_len (inline_bufp);
  1053.  
  1054.   t = (struct pending_inline *)xmalloc (sizeof (struct pending_inline));
  1055.   t->len = inline_bufp - inline_buffer;
  1056.   t->buf = (char *)xmalloc (t->len);
  1057.   bcopy (inline_buffer, t->buf, t->len);
  1058.   t->lineno = lineno;
  1059.   t->filename = input_filename;
  1060.   t->token = 0;
  1061.   return t;
  1062. }
  1063. #endif
  1064.  
  1065. #define OVERLOAD_MAX_LEN 1024
  1066.  
  1067. /* Pretty printing for announce_function.  If BUF is nonzero, then
  1068.    the text is written there.  The buffer is assued to be of size
  1069.    OVERLOAD_MAX_LEN.  CNAME is the name of the class that FNDECL
  1070.    belongs to, if we could not figure that out from FNDECL
  1071.    itself.  FNDECL is the declaration of the function we
  1072.    are interested in seeing.  PRINT_RET_TYPE_P is non-zero if
  1073.    we should print the type that this function returns.  */
  1074. char *
  1075. fndecl_as_string (buf, cname, fndecl, print_ret_type_p)
  1076.      char *buf;
  1077.      tree cname, fndecl;
  1078.      int print_ret_type_p;
  1079. {
  1080.   tree name = DECL_NAME (fndecl);
  1081.   tree fntype = TREE_TYPE (fndecl);
  1082.   tree parmtypes = TYPE_ARG_TYPES (fntype);
  1083.   int p = 0;
  1084.   int spaces = 0;
  1085.  
  1086.   inline_buffer = buf;
  1087.   OB_INIT ();
  1088.  
  1089.   if (DECL_STATIC_FUNCTION_P (fndecl))
  1090.     cname = TYPE_NAME (DECL_STATIC_CONTEXT (fndecl));
  1091.   else if (! cname && TREE_CODE (fntype) == METHOD_TYPE)
  1092.     cname = TYPE_NAME (TYPE_METHOD_BASETYPE (fntype));
  1093.  
  1094.   if (print_ret_type_p && ! OPERATOR_TYPENAME_P (name))
  1095.     dump_type_prefix (TREE_TYPE (fntype), &p);
  1096.   if (DECL_STATIC_FUNCTION_P (fndecl))
  1097.       OB_PUTS ("static ");
  1098.     
  1099.   if (cname)
  1100.     {
  1101.       dump_type (cname, &p);
  1102.       inline_bufp[-1] = ':';
  1103.       *inline_bufp++ = ':';
  1104.       if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes)
  1105.     parmtypes = TREE_CHAIN (parmtypes);
  1106.       if (DECL_CONSTRUCTOR_FOR_VBASE_P (fndecl))
  1107.     /* Skip past "in_charge" identifier.  */
  1108.     parmtypes = TREE_CHAIN (parmtypes);
  1109.     }
  1110.  
  1111.   if (DESTRUCTOR_NAME_P (name))
  1112.     {
  1113.       OB_PUTC ('~');
  1114.       parmtypes = TREE_CHAIN (parmtypes);
  1115.       dump_decl (DECL_ORIGINAL_NAME (fndecl));
  1116.     }
  1117.   else if (OPERATOR_NAME_P (name))
  1118.     {
  1119.       sprintf (inline_bufp, "operator %s ", operator_name_string (name));
  1120.       inline_bufp += strlen (inline_bufp);
  1121.     }
  1122.   else if (OPERATOR_TYPENAME_P (name))
  1123.     {
  1124.       /* This cannot use the hack that the operator's return
  1125.      type is stashed off of its name because it may be
  1126.      used for error reporting.  In the case of conflicting
  1127.      declarations, both will have the same name, yet
  1128.      the types will be different, hence the TREE_TYPE field
  1129.      of the first name will be clobbered by the second.  */
  1130.       OB_PUTS ("operator ");
  1131.       dump_type (TREE_TYPE (TREE_TYPE (fndecl)), &p);
  1132.     }
  1133.   else if (DECL_CONSTRUCTOR_P (fndecl))
  1134.     {
  1135. #ifdef SOS
  1136.       if (TYPE_DYNAMIC (TREE_TYPE (TREE_TYPE (DECL_ORIGINAL_NAME (fndecl)))))
  1137.     {
  1138.       OB_PUTS ("dynamic ");
  1139.       parmtypes = TREE_CHAIN (parmtypes);
  1140.     }
  1141. #endif
  1142.       dump_decl (DECL_ORIGINAL_NAME (fndecl));
  1143.     }
  1144.   else
  1145.     {
  1146. #if 0
  1147.       if (WRAPPER_NAME_P (name))
  1148.     OB_PUTC2 ('(', ')');
  1149.       if (WRAPPER_PRED_NAME_P (name))
  1150.     OB_PUTS ("()?");
  1151.       else if (ANTI_WRAPPER_NAME_P (name))
  1152.     OB_PUTS ("~()");
  1153. #endif
  1154.       dump_decl (DECL_ORIGINAL_NAME (fndecl));
  1155.     }
  1156.  
  1157.   OB_PUTC ('(');
  1158.   if (parmtypes)
  1159.     {
  1160.       in_parmlist++;
  1161.       if (parmtypes != void_list_node)
  1162.     spaces = 2;
  1163.       while (parmtypes && parmtypes != void_list_node)
  1164.     {
  1165.       dump_type (TREE_VALUE (parmtypes), &p);
  1166.       while (inline_bufp[-1] == ' ')
  1167.         inline_bufp--;
  1168.       if (TREE_PURPOSE (parmtypes))
  1169.         {
  1170.           inline_errp = inline_bufp;
  1171.           OB_PUTS (" (= ");
  1172.           dump_init (TREE_PURPOSE (parmtypes));
  1173.           OB_PUTC (')');
  1174.         }
  1175.       OB_PUTC2 (',', ' ');
  1176.       parmtypes = TREE_CHAIN (parmtypes);
  1177.     }
  1178.       in_parmlist--;
  1179.     }
  1180.   
  1181.   if (parmtypes)
  1182.     inline_bufp -= spaces;
  1183.   else
  1184.     OB_PUTS ("...");
  1185.  
  1186.   OB_PUTC (')');
  1187.  
  1188.   if (print_ret_type_p && ! OPERATOR_TYPENAME_P (name))
  1189.     dump_type_suffix (TREE_TYPE (fntype), &p);
  1190.  
  1191.   if (TREE_CODE (fntype) == METHOD_TYPE)
  1192.     dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))));
  1193.  
  1194.   OB_FINISH ();
  1195.   check_text_len (inline_bufp);
  1196.   
  1197.   if (strlen (buf) >= OVERLOAD_MAX_LEN)
  1198.     {
  1199.       fprintf (stderr, "fndecl_as_string returns something too large");
  1200.       abort ();
  1201.     }
  1202.   return buf;
  1203. }
  1204.  
  1205. #ifdef FIELD_XREF
  1206.  
  1207. char *
  1208. type_as_string (buf, typ)
  1209.      char *buf;
  1210.      tree typ;
  1211. {
  1212.   int p = 0;
  1213.   int spaces = 0;
  1214.  
  1215.   inline_buffer = buf;
  1216.   OB_INIT ();
  1217.  
  1218.   dump_type(typ,&p);
  1219.  
  1220.   OB_FINISH ();
  1221.  
  1222.   return buf;
  1223. }
  1224.  
  1225. #endif
  1226.  
  1227. /* Move inline function defintions out of structure so that they
  1228.    can be processed normally.  CNAME is the name of the class
  1229.    we are working from, METHOD_LIST is the list of method lists
  1230.    of the structure.  We delete friend methods here, after
  1231.    saving away their inline function definitions (if any).  */
  1232.  
  1233. /* Subroutine of `do_inline_function_hair'.  */
  1234. static void
  1235. prepare_inline (cname, fndecl)
  1236.      tree cname, fndecl;
  1237. {
  1238.   if (DECL_PENDING_INLINE_INFO (fndecl))
  1239.     {
  1240.       struct pending_inline *t1, *t2;
  1241.       tree args;
  1242.  
  1243.       t2 = DECL_PENDING_INLINE_INFO (fndecl);
  1244.       t2->next = pending_inlines;
  1245.       t2->fndecl = fndecl;
  1246.       args = DECL_ARGUMENTS (fndecl);
  1247.       while (args)
  1248.     {
  1249.       DECL_CONTEXT (args) = fndecl;
  1250.       args = TREE_CHAIN (args);
  1251.     }
  1252. #ifdef DO_METHODS_THE_OLD_WAY
  1253.       t1 = stash_inline_prefix (cname, methods);
  1254.       t1->next = t2;
  1255. #else
  1256.       t1 = t2;
  1257. #endif
  1258.       pending_inlines = t1;
  1259.  
  1260.       /* Allow this decl to be seen in global scope */
  1261.       IDENTIFIER_GLOBAL_VALUE (DECL_NAME (fndecl)) = fndecl;
  1262.     }
  1263. }
  1264.  
  1265. void
  1266. do_inline_function_hair (type, friend_list)
  1267.      tree type, friend_list;
  1268. {
  1269.   tree cname = DECL_NAME (TYPE_NAME (type));
  1270.   tree method_vec = CLASSTYPE_METHOD_VEC (type);
  1271.   if (method_vec != 0)
  1272.     {
  1273.       tree *methods = &TREE_VEC_ELT (method_vec, 0);
  1274.       tree *end = TREE_VEC_END (method_vec);
  1275.       while (methods != end)
  1276.     {
  1277.       /* Do inline member functions.  */
  1278.       tree method = *methods;
  1279.       while (method)
  1280.         {
  1281.           prepare_inline (cname, method);
  1282.           method = TREE_CHAIN (method);
  1283.         }
  1284.       methods++;
  1285.     }
  1286.     }
  1287.   while (friend_list)
  1288.     {
  1289.       prepare_inline (NULL_TREE, TREE_VALUE (friend_list));
  1290.       friend_list = TREE_CHAIN (friend_list);
  1291.     }
  1292. }
  1293.  
  1294. /* Report a argument type mismatch between the best declared function
  1295.    we could find and the current argument list that we have.  */
  1296. void
  1297. report_type_mismatch (cp, parmtypes, name_kind, err_name)
  1298.      struct candidate *cp;
  1299.      tree parmtypes;
  1300.      char *name_kind, *err_name;
  1301. {
  1302.   char buf[OVERLOAD_MAX_LEN];
  1303.   int i = cp->u.bad_arg;
  1304.   tree ttf, tta;
  1305.  
  1306.   if (i == -3)
  1307.     {
  1308.       if (TREE_READONLY (TREE_TYPE (TREE_VALUE (parmtypes))))
  1309.     error ("call to const %s `%s' with non-const object", name_kind, err_name);
  1310.       else
  1311.     error ("call to non-const %s `%s' with const object", name_kind, err_name);
  1312.       return;
  1313.     }
  1314.   if (i == -2)
  1315.     {
  1316.       error ("too few arguments for %s `%s'", name_kind, err_name);
  1317.       return;
  1318.     }
  1319.   else if (i == -1)
  1320.     {
  1321.       error ("too many arguments for %s `%s'", name_kind, err_name);
  1322.       return;
  1323.     }
  1324.   if (i == 0)
  1325.     {
  1326.       if (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE)
  1327.     {
  1328.       /* Happens when we have an ambiguous base class.  */
  1329.       assert (get_base_type (DECL_CONTEXT (cp->function), TREE_TYPE (TREE_TYPE (TREE_VALUE (parmtypes))), 1) == error_mark_node);
  1330.       return;
  1331.     }
  1332.     }
  1333.   ttf = TYPE_ARG_TYPES (TREE_TYPE (cp->function));
  1334.   tta = parmtypes;
  1335.  
  1336.   while (i-- > 0)
  1337.     {
  1338.       ttf = TREE_CHAIN (ttf);
  1339.       tta = TREE_CHAIN (tta);
  1340.     }
  1341.   fndecl_as_string (buf, 0, cp->function, 0);
  1342.   inline_bufp = inline_buffer + strlen (inline_buffer) + 1;
  1343.   inline_buffer = inline_bufp;
  1344.  
  1345.   /* Reset `i' so that type printing routines do the right thing.  */
  1346.   if (tta)
  1347.     {
  1348.       enum tree_code code = TREE_CODE (TREE_TYPE (TREE_VALUE (tta)));
  1349.       if (code == ERROR_MARK)
  1350.     OB_PUTS ("(failed type instatiation)");
  1351.       else
  1352.     {
  1353.       i = (code == FUNCTION_TYPE || code == METHOD_TYPE);
  1354.       dump_type (TREE_TYPE (TREE_VALUE (tta)), &i);
  1355.     }
  1356.     }
  1357.   else OB_PUTS ("void");
  1358.  
  1359.   OB_FINISH ();
  1360.   sprintf (inline_bufp, "bad argument %d for function `%s' (type was %s)",
  1361.        cp->u.bad_arg - (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE), buf, inline_buffer);
  1362.   strcpy (buf, inline_bufp);
  1363.   error (buf);
  1364. }
  1365.  
  1366. /* Here is where overload code starts.  */
  1367.  
  1368. #define OVERLOAD_MAX_LEN 1024
  1369.  
  1370. /* Array of types seen so far in top-level call to `build_overload_name'.
  1371.    Allocated and deallocated by caller.  */
  1372. static tree *typevec;
  1373.  
  1374. /* Number of types interned by `build_overload_name' so far.  */
  1375. static int maxtype;
  1376.  
  1377. /* Number of occurances of last type seen.  */
  1378. static int nrepeats;
  1379.  
  1380. /* Nonzero if we should not try folding parameter types.  */
  1381. static int nofold;
  1382.  
  1383. #define ALLOCATE_TYPEVEC(PARMTYPES) \
  1384.   do { maxtype = 0, nrepeats = 0; \
  1385.        typevec = (tree *)alloca (list_length (PARMTYPES) * sizeof (tree)); } while (0)
  1386.  
  1387. #define DEALLOCATE_TYPEVEC(PARMTYPES) \
  1388.   do { tree t = (PARMTYPES); \
  1389.        while (t) { TREE_USED (TREE_VALUE (t)) = 0; t = TREE_CHAIN (t); } \
  1390.   } while (0)
  1391.  
  1392. /* Code to concatenate an asciified integer to a string,
  1393.    and return the end of the string.  */
  1394. static
  1395. #ifdef __GNUC__
  1396. __inline
  1397. #endif
  1398. char *
  1399. icat (s, i)
  1400.      char *s;
  1401.      int i;
  1402. {
  1403.   if (i < 10)
  1404.     {
  1405.       *s++ = '0' + i;
  1406.       return s;
  1407.     }
  1408.   s = icat (s, i / 10);
  1409.   *s++ = '0' + (i % 10);
  1410.   return s;
  1411. }
  1412.  
  1413. static
  1414. #ifdef __GNUC__
  1415. __inline
  1416. #endif
  1417. char *
  1418. flush_repeats (s, type)
  1419.      char *s;
  1420.      tree type;
  1421. {
  1422.   int tindex = 0;
  1423.   char *rval;
  1424.  
  1425.   while (typevec[tindex] != type)
  1426.     tindex++;
  1427.  
  1428.   if (nrepeats > 1)
  1429.     {
  1430.       *s++ = 'N';
  1431.       s = icat (s, nrepeats);
  1432.       if (nrepeats > 9)
  1433.     *s++ = '_';
  1434.     }
  1435.   else
  1436.     *s++ = 'T';
  1437.   nrepeats = 0;
  1438.   rval = icat (s, tindex);
  1439.   if (tindex > 9)
  1440.     *rval++ = '_';
  1441.   return rval;
  1442. }
  1443.  
  1444. /* Given a list of parameters in PARMS, and a buffer in TEXT, of
  1445.    length LEN bytes, create an unambiguous overload string. Should
  1446.    distinguish any type that C (or C++) can distinguish. I.e.,
  1447.    pointers to functions are treated correctly.
  1448.  
  1449.    Caller must deal with whether a final `e' goes on the end or not.
  1450.  
  1451.    Any default conversions must take place before this function
  1452.    is called.  */
  1453.  
  1454. static char *
  1455. build_overload_name (parmtypes, text, text_end)
  1456.      tree parmtypes;
  1457.      char *text, *text_end;
  1458. {
  1459.   char *textp = text;
  1460.   int just_one;
  1461.   tree parmtype;
  1462.  
  1463.   if (just_one = (TREE_CODE (parmtypes) != TREE_LIST))
  1464.     {
  1465.       parmtype = parmtypes;
  1466.       goto only_one;
  1467.     }
  1468.  
  1469.   while (parmtypes)
  1470.     {
  1471.       if (text_end - text < 4)
  1472.     fatal ("Out of string space in build_overload_name!");
  1473.       parmtype = TREE_VALUE (parmtypes);
  1474.  
  1475.     only_one:
  1476.  
  1477.       if (! nofold)
  1478.     {
  1479.       if (! just_one)
  1480.         /* Every argument gets counted.  */
  1481.         typevec[maxtype++] = parmtype;
  1482.  
  1483.       if (TREE_USED (parmtype))
  1484.         {
  1485.           if (! just_one && parmtype == typevec[maxtype-2])
  1486.         nrepeats++;
  1487.           else
  1488.         {
  1489.           if (nrepeats)
  1490.             textp = flush_repeats (textp, parmtype);
  1491.           if (! just_one && TREE_CHAIN (parmtypes)
  1492.               && parmtype == TREE_VALUE (TREE_CHAIN (parmtypes)))
  1493.             nrepeats++;
  1494.           else
  1495.             {
  1496.               int tindex = 0;
  1497.  
  1498.               while (typevec[tindex] != parmtype)
  1499.             tindex++;
  1500.               *textp++ = 'T';
  1501.               textp = icat (textp, tindex);
  1502.               if (tindex > 9)
  1503.             *textp++ = '_';
  1504.             }
  1505.         }
  1506.           goto next;
  1507.         }
  1508.       if (nrepeats)
  1509.         textp = flush_repeats (textp, typevec[maxtype-2]);
  1510.       if (! just_one
  1511.           /* Only cache types which take more than one character.  */
  1512.           && (parmtype != TYPE_MAIN_VARIANT (parmtype)
  1513.           || (TREE_CODE (parmtype) != INTEGER_TYPE
  1514.               && TREE_CODE (parmtype) != REAL_TYPE)))
  1515.         TREE_USED (parmtype) = 1;
  1516.     }
  1517.  
  1518.       if (TREE_READONLY (parmtype))
  1519.     *textp++ = 'C';
  1520.       if (TREE_CODE (parmtype) == INTEGER_TYPE && TREE_UNSIGNED (parmtype))
  1521.     *textp++ = 'U';
  1522.       if (TREE_VOLATILE (parmtype))
  1523.     *textp++ = 'V';
  1524.  
  1525.       switch (TREE_CODE (parmtype))
  1526.     {
  1527.     case OFFSET_TYPE:
  1528.       *textp++ = 'O';
  1529.       textp = build_overload_name (TYPE_OFFSET_BASETYPE (parmtype), textp, text_end);
  1530.       *textp++ = '_';
  1531.       textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end);
  1532.       break;
  1533.  
  1534.     case REFERENCE_TYPE:
  1535.       *textp++ = 'R';
  1536.       goto more;
  1537.  
  1538.     case ARRAY_TYPE:
  1539. #ifdef PARM_CAN_BE_ARRAY_TYPE
  1540.       {
  1541.         tree length;
  1542.  
  1543.         *textp++ = 'A';
  1544.         length = array_type_nelts (parmtype);
  1545.         if (TREE_CODE (length) == INTEGER_CST)
  1546.           textp = icat (textp, TREE_INT_CST_LOW (length));
  1547.         *textp++ = '_';
  1548.         goto more;
  1549.       }
  1550. #else
  1551.       *textp++ = 'P';
  1552.       goto more;
  1553. #endif
  1554.  
  1555.     case POINTER_TYPE:
  1556.       *textp++ = 'P';
  1557.     more:
  1558.       textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end);
  1559.       break;
  1560.  
  1561.     case FUNCTION_TYPE:
  1562.     case METHOD_TYPE:
  1563.       {
  1564.         tree firstarg = TYPE_ARG_TYPES (parmtype);
  1565.         /* Otherwise have to implement reentrant typevecs,
  1566.            unmark and remark types, etc.  */
  1567.         int old_nofold = nofold;
  1568.         nofold = 1;
  1569.  
  1570.         if (nrepeats)
  1571.           textp = flush_repeats (textp, typevec[maxtype-1]);
  1572.  
  1573.         /* @@ It may be possible to pass a function type in
  1574.            which is not preceded by a 'P'.  */
  1575.         if (TREE_CODE (parmtype) == FUNCTION_TYPE)
  1576.           {
  1577.         *textp++ = 'F';
  1578.         if (firstarg == NULL_TREE)
  1579.           *textp++ = 'e';
  1580.         else if (firstarg == void_list_node)
  1581.           *textp++ = 'v';
  1582.         else
  1583.           textp = build_overload_name (firstarg, textp, text_end);
  1584.           }
  1585.         else
  1586.           {
  1587.         int constp = TREE_READONLY (TREE_TYPE (TREE_VALUE (firstarg)));
  1588.         int volatilep = TREE_VOLATILE (TREE_TYPE (TREE_VALUE (firstarg)));
  1589.         *textp++ = 'M';
  1590.         firstarg = TREE_CHAIN (firstarg);
  1591.  
  1592.         textp = build_overload_name (TYPE_METHOD_BASETYPE (parmtype), textp, text_end);
  1593.         if (constp)
  1594.           *textp++ = 'C';
  1595.         if (volatilep)
  1596.           *textp++ = 'V';
  1597.  
  1598.         /* For cfront 2.0 compatability.  */
  1599.         *textp++ = 'F';
  1600.  
  1601.         if (firstarg == NULL_TREE)
  1602.           *textp++ = 'e';
  1603.         else if (firstarg == void_list_node)
  1604.           *textp++ = 'v';
  1605.         else
  1606.           textp = build_overload_name (firstarg, textp, text_end);
  1607.           }
  1608.  
  1609.         /* Separate args from return type.  */
  1610.         *textp++ = '_';
  1611.         textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end);
  1612.         nofold = old_nofold;
  1613.         break;
  1614.       }
  1615.  
  1616.     case INTEGER_TYPE:
  1617.       parmtype = TYPE_MAIN_VARIANT (parmtype);
  1618.       switch (TYPE_MODE (parmtype))
  1619.         {
  1620.         case TImode:
  1621.           if (parmtype == long_integer_type_node
  1622.           || parmtype == long_unsigned_type_node)
  1623.         *textp++ = 'l';
  1624.           else
  1625.         *textp++ = 'q';
  1626.           break;
  1627.         case DImode:
  1628.           if (parmtype == long_integer_type_node
  1629.           || parmtype == long_unsigned_type_node)
  1630.         *textp++ = 'l';
  1631.           else if (parmtype == integer_type_node
  1632.                || parmtype == unsigned_type_node)
  1633.         *textp++ = 'i';
  1634.           else if (parmtype == short_integer_type_node
  1635.                || parmtype == short_unsigned_type_node)
  1636.         *textp++ = 's';
  1637.           else
  1638.         *textp++ = 'x';
  1639.           break;
  1640.         case SImode:
  1641.           if (parmtype == long_integer_type_node
  1642.           || parmtype == long_unsigned_type_node)
  1643.         *textp++ = 'l';
  1644.           else if (parmtype == short_integer_type_node
  1645.                || parmtype == short_unsigned_type_node)
  1646.         *textp++ = 's';
  1647.           else
  1648.         *textp++ = 'i';
  1649.           break;
  1650.         case HImode:
  1651.           if (parmtype == integer_type_node
  1652.           || parmtype == unsigned_type_node)
  1653.         *textp++ = 'i';
  1654.           else
  1655.         *textp++ = 's';
  1656.           break;
  1657.         case QImode:
  1658.           *textp++ = 'c';
  1659.           break;
  1660.         default:
  1661.           abort ();
  1662.         }
  1663.       break;
  1664.  
  1665.     case REAL_TYPE:
  1666.       parmtype = TYPE_MAIN_VARIANT (parmtype);
  1667.       if (parmtype == long_double_type_node)
  1668.         *textp++ = 'r';
  1669.       else if (parmtype == double_type_node)
  1670.         *textp++ = 'd';
  1671.       else if (parmtype == float_type_node)
  1672.         *textp++ = 'f';
  1673.       else abort ();
  1674.       break;
  1675.  
  1676.     case VOID_TYPE:
  1677.       if (! just_one)
  1678.         {
  1679. #if 0
  1680.           extern tree void_list_node;
  1681.  
  1682.           /* See if anybody is wasting memory.  */
  1683.           assert (parmtypes == void_list_node);
  1684. #endif
  1685.           /* This is the end of a parameter list.  */
  1686.           *textp = '\0';
  1687.           return textp;
  1688.         }
  1689.       *textp++ = 'v';
  1690.       break;
  1691.  
  1692.     case ERROR_MARK:    /* not right, but nothing is anyway */
  1693.       break;
  1694.  
  1695.       /* have to do these */
  1696.     case UNION_TYPE:
  1697.     case RECORD_TYPE:
  1698.       if (! just_one)
  1699.         /* Make this type signature look incompatible
  1700.            with AT&T.  */
  1701.         *textp++ = 'G';
  1702.       goto common;
  1703.     case ENUMERAL_TYPE:
  1704.     common:
  1705.       {
  1706.         tree name = TYPE_NAME (parmtype);
  1707.         if (TREE_CODE (name) == TYPE_DECL)
  1708.           name = DECL_NAME (name);
  1709.         assert (TREE_CODE (name) == IDENTIFIER_NODE);
  1710.         textp = icat (textp, IDENTIFIER_LENGTH (name));
  1711.         strcpy (textp, IDENTIFIER_POINTER (name));
  1712.         textp += IDENTIFIER_LENGTH (name);
  1713.         break;
  1714.       }
  1715.  
  1716.     case UNKNOWN_TYPE:
  1717.       /* This will take some work.  */
  1718.       *textp++ = '?';
  1719.       break;
  1720.  
  1721.     default:
  1722.       abort ();
  1723.     }
  1724.  
  1725.     next:
  1726.       if (just_one) break;
  1727.       parmtypes = TREE_CHAIN (parmtypes);
  1728.     }
  1729.   if (! just_one)
  1730.     {
  1731.       if (nrepeats)
  1732.     textp = flush_repeats (textp, typevec[maxtype-1]);
  1733.  
  1734.       /* To get here, parms must end with `...'. */
  1735.       *textp++ = 'e';
  1736.     }
  1737.  
  1738.   *textp = '\0';
  1739.   return textp;
  1740. }
  1741.  
  1742. /* Change the name of a function definition so that it may be
  1743.    overloaded. NAME is the name of the function to overload,
  1744.    PARMS is the parameter list (which determines what name the
  1745.    final function obtains).
  1746.  
  1747.    FOR_METHOD is 1 if this overload is being performed
  1748.    for a method, rather than a function type.  It is 2 if
  1749.    this overload is being performed for a constructor.  */
  1750. tree
  1751. build_decl_overload (name, parms, for_method)
  1752.      char *name;
  1753.      tree parms;
  1754.      int for_method;
  1755. {
  1756.   int tmp;
  1757.   char tname[OVERLOAD_MAX_LEN];
  1758.  
  1759.   if (for_method == 2)
  1760.     /* We can divine that this is a constructor,
  1761.        and figure out its name without any extra encoding.  */
  1762.     tmp = 0;
  1763.   else
  1764.     {
  1765.       strcpy (tname, name);
  1766.       tmp = strlen (tname);
  1767.     }
  1768.   tname[tmp++] = '_';
  1769.   tname[tmp++] = '_';
  1770.   if (for_method)
  1771.     {
  1772. #if 0
  1773.       /* We can get away without doing this.  */
  1774.       tname[tmp++] = 'M';
  1775. #endif
  1776.       parms = temp_tree_cons (NULL_TREE, TREE_TYPE (TREE_VALUE (parms)), TREE_CHAIN (parms));
  1777.     }
  1778.   else
  1779.     tname[tmp++] = 'F';
  1780.  
  1781.   if (parms == NULL_TREE)
  1782.     tname[tmp++] = 'e', tname[tmp] = '\0';
  1783.   else if (parms == void_list_node)
  1784.     tname[tmp++] = 'v', tname[tmp] = '\0';
  1785.   else
  1786.     {
  1787.       ALLOCATE_TYPEVEC (parms);
  1788.       nofold = 0;
  1789.       if (for_method)
  1790.     {
  1791.       tmp = build_overload_name (TREE_VALUE (parms), tname+tmp, &tname[OVERLOAD_MAX_LEN]) - tname;
  1792.  
  1793. #ifndef LONGERNAMES
  1794.       typevec[maxtype++] = TREE_VALUE (parms);
  1795.       TREE_USED (TREE_VALUE (parms)) = 1;
  1796. #endif
  1797.  
  1798.       if (TREE_CHAIN (parms))
  1799.         build_overload_name (TREE_CHAIN (parms), tname+tmp, &tname[OVERLOAD_MAX_LEN]);
  1800.       else
  1801.         {
  1802.           tname[tmp++] = 'e';
  1803.           tname[tmp] = '\0';
  1804.         }
  1805.     }
  1806.       else
  1807.     build_overload_name (parms, tname+tmp, &tname[OVERLOAD_MAX_LEN]);
  1808.       DEALLOCATE_TYPEVEC (parms);
  1809.     }
  1810.   return get_identifier (tname);
  1811. }
  1812.  
  1813. /* Build an overload name for the type expression TYPE.  */
  1814. tree
  1815. build_typename_overload (type)
  1816.      tree type;
  1817. {
  1818.   char tname[OVERLOAD_MAX_LEN];
  1819.   int i = sizeof (OPERATOR_TYPENAME_FORMAT) - 1;
  1820.   sprintf (tname, OPERATOR_TYPENAME_FORMAT);
  1821. #if 0
  1822.   /* We can get away without doing this--it really gets
  1823.      overloaded later.  */
  1824.   tname[i++] = '_';
  1825.   tname[i++] = '_';
  1826.   tname[i++] = 'M';
  1827. #endif
  1828.   nofold = 1;
  1829.   build_overload_name (type, tname + i, &tname[OVERLOAD_MAX_LEN]);
  1830.   return get_identifier (tname);
  1831. }
  1832.  
  1833. /* Top-level interface to explicit overload requests. Allow NAME
  1834.    to be overloaded. Error if NAME is already declared for the current
  1835.    scope. Warning if function is redundanly overloaded. */
  1836.  
  1837. void
  1838. declare_overloaded (name)
  1839.      tree name;
  1840. {
  1841. #ifdef NO_AUTO_OVERLOAD
  1842.   if (is_overloaded (name))
  1843.     warning ("function `%s' already declared overloaded",
  1844.          IDENTIFIER_POINTER (name));
  1845.   else if (IDENTIFIER_GLOBAL_VALUE (name))
  1846.     error ("overloading function `%s' that is already defined",
  1847.        IDENTIFIER_POINTER (name));
  1848.   else
  1849.     {
  1850.       TREE_OVERLOADED (name) = 1;
  1851.       IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE);
  1852.       TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node;
  1853.     }
  1854. #else
  1855.   if (current_lang_name == lang_name_cplusplus)
  1856.     {
  1857.       if (0)
  1858.     warning ("functions are implicitly overloaded in C++");
  1859.     }
  1860.   else if (current_lang_name == lang_name_c)
  1861.     error ("overloading function `%s' cannot be done in C language context");
  1862.   else
  1863.     abort ();
  1864. #endif
  1865. }
  1866.  
  1867. #ifdef NO_AUTO_OVERLOAD
  1868. /* Check to see if NAME is overloaded. For first approximation,
  1869.    check to see if its TREE_OVERLOADED is set.  This is used on
  1870.    IDENTIFIER nodes.  */
  1871. int
  1872. is_overloaded (name)
  1873.      tree name;
  1874. {
  1875.   /* @@ */
  1876.   return (TREE_OVERLOADED (name)
  1877.       && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0)
  1878.       && ! IDENTIFIER_LOCAL_VALUE (name));
  1879. }
  1880. #endif
  1881.  
  1882. /* Given a tree_code CODE, and some arguments (at least one),
  1883.    attempt to use an overloaded operator on the arguments.
  1884.  
  1885.    For unary operators, only the first argument need be checked.
  1886.    For binary operators, both arguments may need to be checked.
  1887.  
  1888.    Member functions can convert class references to class pointers,
  1889.    for one-level deep indirection.  More than that is not supported.
  1890.    Operators [](), ()(), and ->() must be member functions.
  1891.  
  1892.    We call function call building calls with nonzero complain if
  1893.    they are our only hope.  This is true when we see a vanilla operator
  1894.    applied to something of aggregate type.  If this fails, we are free to
  1895.    return `error_mark_node', because we will have reported the error.
  1896.  
  1897.    Operators NEW and DELETE overload in funny ways: operator new takes
  1898.    a single `size' parameter, and operator delete takes a pointer to the
  1899.    storage being deleted.  When overloading these operators, success is
  1900.    assumed.  If there is a failure, report an error message and return
  1901.    `error_mark_node'.  */
  1902.  
  1903. /* NOSTRICT */
  1904. tree
  1905. build_opfncall (code, flags, xarg1, xarg2, arg3)
  1906.      enum tree_code code;
  1907.      tree xarg1, xarg2;
  1908.      tree arg3;
  1909. {
  1910.   tree rval = 0;
  1911.   tree arg1, arg2;
  1912.   tree type1, type2, fnname;
  1913.   tree fields1 = 0, parms = 0;
  1914.   tree global_fn;
  1915.   int try_second;
  1916.   int binary_is_unary;
  1917.  
  1918.   if (xarg1 == error_mark_node)
  1919.     return error_mark_node;
  1920.  
  1921.   if (code == COND_EXPR)
  1922.     {
  1923.       if (TREE_CODE (xarg2) == ERROR_MARK
  1924.       || TREE_CODE (arg3) == ERROR_MARK)
  1925.     return error_mark_node;
  1926.     }
  1927.   if (code == COMPONENT_REF)
  1928.     if (TREE_CODE (TREE_TYPE (xarg1)) == POINTER_TYPE)
  1929.       return rval;
  1930.  
  1931.   /* First, see if we can work with the first argument */
  1932.   type1 = TREE_TYPE (xarg1);
  1933.  
  1934.   /* Some tree codes have length > 1, but we really only want to
  1935.      overload them if their first argument has a user defined type.  */
  1936.   switch (code)
  1937.     {
  1938.     case PREINCREMENT_EXPR:
  1939.       code = POSTINCREMENT_EXPR;
  1940.       binary_is_unary = 1;
  1941.       try_second = 0;
  1942.       break;
  1943.  
  1944.     case POSTDECREMENT_EXPR:
  1945.       code = PREDECREMENT_EXPR;
  1946.       binary_is_unary = 1;
  1947.       try_second = 0;
  1948.       break;
  1949.  
  1950.     case PREDECREMENT_EXPR:
  1951.     case POSTINCREMENT_EXPR:
  1952.     case COMPONENT_REF:
  1953.       binary_is_unary = 1;
  1954.       try_second = 0;
  1955.       break;
  1956.  
  1957.       /* ARRAY_REFs and CALL_EXPRs must overload successfully.
  1958.      If they do not, return error_mark_node instead of NULL_TREE.  */
  1959.     case ARRAY_REF:
  1960.       if (xarg2 == error_mark_node)
  1961.     return error_mark_node;
  1962.     case CALL_EXPR:
  1963.       rval = error_mark_node;
  1964.       binary_is_unary = 0;
  1965.       try_second = 0;
  1966.       break;
  1967.  
  1968.     case NEW_EXPR:
  1969.       {
  1970.     /* For operators `new' (`delete'), only check visibility
  1971.        if we are in a constructor (destructor), and we are
  1972.        allocating for that constructor's (destructor's) type.  */
  1973.  
  1974.     fnname = get_identifier (OPERATOR_NEW_FORMAT);
  1975.     if (flags & LOOKUP_GLOBAL)
  1976.       return build_overload_call (fnname, tree_cons (NULL_TREE, xarg2, arg3),
  1977.                       flags & LOOKUP_COMPLAIN, 0);
  1978.  
  1979.     if (current_function_decl == NULL_TREE
  1980.         || !DECL_CONSTRUCTOR_P (current_function_decl)
  1981.         || current_class_type != TYPE_MAIN_VARIANT (type1))
  1982.       flags = LOOKUP_COMPLAIN;
  1983.     rval = build_method_call (build1 (NOP_EXPR, xarg1, error_mark_node),
  1984.                   fnname, tree_cons (NULL_TREE, xarg2, arg3),
  1985.                   NULL_TREE, flags);
  1986.     if (rval == error_mark_node)
  1987.       /* User might declare fancy operator new, but invoke it
  1988.          like standard one.  */
  1989.       return rval;
  1990.  
  1991.     TREE_TYPE (rval) = xarg1;
  1992.     TREE_CALLS_NEW (rval) = 1;
  1993.     return rval;
  1994.       }
  1995.       break;
  1996.  
  1997.     case DELETE_EXPR:
  1998.       {
  1999.     /* See comment above.  */
  2000.  
  2001.     fnname = get_identifier (OPERATOR_DELETE_FORMAT);
  2002.     if (flags & LOOKUP_GLOBAL)
  2003.       return build_overload_call (fnname, build_tree_list (NULL_TREE, xarg1),
  2004.                       flags & LOOKUP_COMPLAIN, 0);
  2005.  
  2006.     if (current_function_decl == NULL_TREE
  2007.         || !DESTRUCTOR_NAME_P (DECL_NAME (current_function_decl))
  2008.         || current_class_type != TYPE_MAIN_VARIANT (type1))
  2009.       flags = LOOKUP_COMPLAIN;
  2010.     rval = build_method_call (build1 (NOP_EXPR, TREE_TYPE (xarg1), error_mark_node),
  2011.                   fnname, build_tree_list (NULL_TREE, xarg1),
  2012.                   NULL_TREE, flags);
  2013.     /* This happens when the user mis-declares `operator delete'.
  2014.        Should now be impossible.  */
  2015.     assert (rval != error_mark_node);
  2016.     TREE_TYPE (rval) = void_type_node;
  2017.     return rval;
  2018.       }
  2019.       break;
  2020.  
  2021.     default:
  2022.       binary_is_unary = 0;
  2023.       try_second = tree_code_length [(int) code] == 2;
  2024.       if (xarg2 == error_mark_node)
  2025.     return error_mark_node;
  2026.       break;
  2027.     }
  2028.  
  2029.   if (try_second && xarg2 == error_mark_node)
  2030.     return error_mark_node;
  2031.  
  2032.   /* What ever it was, we do not know how to deal with it.  */
  2033.   if (type1 == NULL_TREE)
  2034.     return rval;
  2035.  
  2036.   if (TREE_CODE (type1) == OFFSET_TYPE)
  2037.     type1 = TREE_TYPE (type1);
  2038.  
  2039.   if (TREE_CODE (type1) == REFERENCE_TYPE)
  2040.     {
  2041.       arg1 = convert_from_reference (xarg1);
  2042.       type1 = TREE_TYPE (arg1);
  2043.     }
  2044.   else
  2045.     {
  2046.       arg1 = xarg1;
  2047.     }
  2048.  
  2049.   if (!IS_AGGR_TYPE (type1))
  2050.     {
  2051.       /* Try to fail. First, fail if unary */
  2052.       if (! try_second)
  2053.     return rval;
  2054.       /* Second, see if second argument is non-aggregate. */
  2055.       type2 = TREE_TYPE (xarg2);
  2056.       if (TREE_CODE (type2) == OFFSET_TYPE)
  2057.     type2 = TREE_TYPE (type2);
  2058.       if (TREE_CODE (type2) == REFERENCE_TYPE)
  2059.     {
  2060.       arg2 = convert_from_reference (xarg2);
  2061.       type2 = TREE_TYPE (arg2);
  2062.     }
  2063.       else
  2064.     {
  2065.       arg2 = xarg2;
  2066.     }
  2067.  
  2068.       if (!IS_AGGR_TYPE (type2))
  2069.     return rval;
  2070.       try_second = 0;
  2071.     }
  2072.  
  2073.   if (try_second)
  2074.     {
  2075.       /* First arg may succeed; see whether second should.  */
  2076.       type2 = TREE_TYPE (xarg2);
  2077.       if (TREE_CODE (type2) == OFFSET_TYPE)
  2078.     type2 = TREE_TYPE (type2);
  2079.       if (TREE_CODE (type2) == REFERENCE_TYPE)
  2080.     {
  2081.       arg2 = convert_from_reference (xarg2);
  2082.       type2 = TREE_TYPE (arg2);
  2083.     }
  2084.       else
  2085.     {
  2086.       arg2 = xarg2;
  2087.     }
  2088.  
  2089.       if (! IS_AGGR_TYPE (type2))
  2090.     try_second = 0;
  2091.     }
  2092.  
  2093.   if (type1 == unknown_type_node
  2094.       || (try_second && TREE_TYPE (xarg2) == unknown_type_node))
  2095.     {
  2096.       /* This will not be implemented in the forseeable future.  */
  2097.       return rval;
  2098.     }
  2099.  
  2100.   if (code == MODIFY_EXPR)
  2101.     {
  2102.       tree op_id = build_opid (MODIFY_EXPR, arg3);
  2103.       fnname = build_operator_fnname (&op_id, 0, 2);
  2104.     }
  2105.   else
  2106.     {
  2107.       tree op_id = build_opid (0, code);
  2108.       if (binary_is_unary)
  2109.     fnname = build_operator_fnname (&op_id, 0, 1);
  2110.       else
  2111.     fnname = build_operator_fnname (&op_id, 0,
  2112.                     tree_code_length [(int) code]);
  2113.     }
  2114.  
  2115.   global_fn = IDENTIFIER_GLOBAL_VALUE (fnname);
  2116.  
  2117.   /* This is the last point where we will accept failure.  This
  2118.      may be too eager if we wish an overloaded operator not to match,
  2119.      but would rather a normal operator be called on a type-converted
  2120.      argument.  */
  2121.  
  2122.   if (IS_AGGR_TYPE (type1))
  2123.     fields1 = lookup_fnfields (CLASSTYPE_AS_LIST (type1), fnname, 0);
  2124.  
  2125.   if (fields1 == NULL_TREE && global_fn == NULL_TREE)
  2126.     return rval;
  2127.  
  2128.   /* If RVAL winds up being `error_mark_node', we will return
  2129.      that... There is no way that normal semantics of these
  2130.      operators will succeed.  */
  2131.  
  2132.   /* This argument may be an uncommited OFFSET_REF.  This is
  2133.      the case for example when dealing with static class members
  2134.      which are referenced from their class name rather than
  2135.      from a class instance.  */
  2136.   if (TREE_CODE (xarg1) == OFFSET_REF
  2137.       && TREE_CODE (TREE_OPERAND (xarg1, 1)) == VAR_DECL)
  2138.     xarg1 = TREE_OPERAND (xarg1, 1);
  2139.   if (try_second && xarg2 && TREE_CODE (xarg2) == OFFSET_REF
  2140.       && TREE_CODE (TREE_OPERAND (xarg2, 1)) == VAR_DECL)
  2141.     xarg2 = TREE_OPERAND (xarg2, 1);
  2142.  
  2143.   if (global_fn)
  2144.     flags |= LOOKUP_GLOBAL;
  2145.  
  2146.   if (code == CALL_EXPR)
  2147.     {
  2148.       /* This can only be a member function.  */
  2149.       return build_method_call (xarg1, fnname, xarg2,
  2150.                 NULL_TREE, LOOKUP_NORMAL);
  2151.     }
  2152.   else if (tree_code_length[(int) code] == 1 || binary_is_unary)
  2153.     {
  2154.       parms = NULL_TREE;
  2155.       rval = build_method_call (xarg1, fnname, NULL_TREE, NULL_TREE, flags);
  2156.     }
  2157.   else if (code == COND_EXPR)
  2158.     {
  2159.       parms = tree_cons (0, xarg2, build_tree_list (0, arg3));
  2160.       rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
  2161.     }
  2162.   else if (code == METHOD_CALL_EXPR)
  2163.     {
  2164.       /* must be a member function.  */
  2165.       parms = tree_cons (NULL_TREE, xarg2, arg3);
  2166.       return build_method_call (xarg1, fnname, parms, NULL_TREE, LOOKUP_NORMAL);
  2167.     }
  2168.   else if (fields1)
  2169.     {
  2170.       parms = build_tree_list (NULL_TREE, xarg2);
  2171.       rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
  2172.     }
  2173.   else
  2174.     {
  2175.       parms = tree_cons (NULL_TREE, xarg1,
  2176.              build_tree_list (NULL_TREE, xarg2));
  2177.       rval = build_overload_call (fnname, parms, flags & LOOKUP_COMPLAIN, 0);
  2178.     }
  2179.  
  2180.   /* If we did not win, do not lose yet, since type conversion may work.  */
  2181.   if (TREE_CODE (rval) == ERROR_MARK)
  2182.     {
  2183.       if (flags & LOOKUP_COMPLAIN)
  2184.     return rval;
  2185.       return 0;
  2186.     }
  2187.  
  2188.   return rval;
  2189. }
  2190.  
  2191. /* This function takes an identifier, ID, and attempts to figure out what
  2192.    it means. There are a number of possible scenarios, presented in increasing
  2193.    order of hair:
  2194.  
  2195.    1) not in a class's scope
  2196.    2) in class's scope, member name of the class's method
  2197.    3) in class's scope, but not a member name of the class
  2198.    4) in class's scope, member name of a class's variable
  2199.  
  2200.    NAME is $1 from the bison rule. It is an IDENTIFIER_NODE.
  2201.    VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1)
  2202.    yychar is the pending input character (suitably encoded :-).
  2203.  
  2204.    As a last ditch, try to look up the name as a label and return that
  2205.    address.
  2206.  
  2207.    Values which are declared as being of REFERENCE_TYPE are
  2208.    automatically dereferenced here (as a hack to make the
  2209.    compiler faster).  */
  2210.  
  2211. tree
  2212. hack_identifier (value, name, yychar)
  2213.      tree value, name;
  2214. {
  2215.   tree type;
  2216.  
  2217.   if (TREE_CODE (value) == ERROR_MARK)
  2218.     {
  2219.       if (current_class_name)
  2220.     {
  2221.       tree fields = lookup_fnfields (CLASSTYPE_AS_LIST (current_class_type), name, 0);
  2222.       if (fields)
  2223.         {
  2224.           fields = TREE_VALUE (fields);
  2225.           assert (TREE_CODE (fields) == FUNCTION_DECL);
  2226.           if (TREE_CHAIN (fields) == NULL_TREE)
  2227.         {
  2228.           warning ("methods cannot be converted to function pointers");
  2229.           return fields;
  2230.         }
  2231.           else
  2232.         {
  2233.           error ("ambiguous request for method pointer `%s'",
  2234.              IDENTIFIER_POINTER (name));
  2235.           return error_mark_node;
  2236.         }
  2237.         }
  2238.     }
  2239.       if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name))
  2240.     {
  2241.       return IDENTIFIER_LABEL_VALUE (name);
  2242.     }
  2243.       return error_mark_node;
  2244.     }
  2245.  
  2246.   type = TREE_TYPE (value);
  2247.   if (TREE_NONLOCAL (value))
  2248.     {
  2249.       if (TREE_CODE (value) == FIELD_DECL)
  2250.     {
  2251.       if (current_class_decl == NULL_TREE)
  2252.         {
  2253.           error ("request for member `%s' in static member function",
  2254.              IDENTIFIER_POINTER (DECL_NAME (value)));
  2255.           return error_mark_node;
  2256.         }
  2257.       TREE_USED (current_class_decl) = 1;
  2258.       if (yychar == '(')
  2259.         if (! ((TYPE_LANG_SPECIFIC (type)
  2260.             && TYPE_OVERLOADS_CALL_EXPR (type))
  2261.            || (TREE_CODE (type) == REFERENCE_TYPE
  2262.                && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
  2263.                && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (type))))
  2264.         && TREE_CODE (type) != FUNCTION_TYPE
  2265.         && TREE_CODE (type) != METHOD_TYPE
  2266.         && (TREE_CODE (type) != POINTER_TYPE
  2267.             || (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
  2268.             && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)))
  2269.         {
  2270.           error ("component `%s' is not a method",
  2271.              IDENTIFIER_POINTER (name));
  2272.           return error_mark_node;
  2273.         }
  2274.       /* Mark so that if we are in a constructor, and then find that
  2275.          this field was initialized by a base initializer,
  2276.          we can emit an error message.  */
  2277.       TREE_USED (value) = 1;
  2278.       return build_component_ref (C_C_D, name, 0, 1);
  2279.     }
  2280.       if (DECL_CONTEXT (value) != current_class_type
  2281.       && (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == CONST_DECL))
  2282.     {
  2283.       tree path;
  2284.       enum visibility_type visibility;
  2285.  
  2286.       get_base_distance (DECL_CONTEXT (value), current_class_type, 0, &path);
  2287.       visibility = compute_visibility (path, value);
  2288.       if (visibility != visibility_public)
  2289.         {
  2290.           if (TREE_CODE (value) == VAR_DECL)
  2291.         error ("static member `%s' is from private base class",
  2292.                IDENTIFIER_POINTER (name));
  2293.           else
  2294.         error ("enum `%s' is from private base class",
  2295.                IDENTIFIER_POINTER (name));
  2296.           return error_mark_node;
  2297.         }
  2298.     }
  2299.       else if (TREE_CODE (value) == TREE_LIST && type == 0)
  2300.     {
  2301.       error ("request for member `%s' is ambiguous in multiple inheritance lattice",
  2302.          IDENTIFIER_POINTER (name));
  2303.       return error_mark_node;
  2304.     }
  2305.  
  2306.       return value;
  2307.     }
  2308.  
  2309.   if (! TREE_USED (value))
  2310.     {
  2311.       if (TREE_EXTERNAL (value))
  2312.     assemble_external (value);
  2313.       TREE_USED (value) = 1;
  2314.     }
  2315.   if (TREE_CODE (type) == REFERENCE_TYPE)
  2316.     {
  2317.       if (! (TREE_CODE (value) == VAR_DECL
  2318.           || TREE_CODE (value) == PARM_DECL
  2319.           || TREE_CODE (value) == RESULT_DECL))
  2320.     abort ();
  2321.       if (DECL_REFERENCE_SLOT (value))
  2322.     return DECL_REFERENCE_SLOT (value);
  2323.     }
  2324.   return value;
  2325. }
  2326.  
  2327. tree
  2328. hack_operator (op)
  2329.      tree op;
  2330. {
  2331.   if (op == NULL_TREE)
  2332.     return error_mark_node;
  2333.  
  2334.   if (TREE_CODE (op) != TYPE_EXPR)
  2335.     return grokopexpr (&op, NULL_TREE, 0, 0, 0);
  2336.  
  2337.   return op;
  2338. }
  2339.  
  2340. /* NONWRAPPER is nonzero if this call is not to be wrapped.
  2341.    TYPE is the type that the wrapper belongs to (in case
  2342.    it should be non-virtual).
  2343.    DECL is the function will will be (not be) wrapped.  */
  2344. tree
  2345. hack_wrapper (nonwrapper, type, decl)
  2346.      int nonwrapper;
  2347.      tree type, decl;
  2348. {
  2349.   if (type == NULL_TREE || is_aggr_typedef (type, 1))
  2350.     {
  2351.       if (type)
  2352.     type = TREE_TYPE (type);
  2353.  
  2354.       switch (nonwrapper)
  2355.     {
  2356.     case 0:
  2357.       return build_nt (WRAPPER_EXPR, type, decl);
  2358.     case 1:
  2359.       return build_nt (ANTI_WRAPPER_EXPR, type, decl);
  2360.     case 2:
  2361.       return build_nt (WRAPPER_EXPR, type,
  2362.                build_nt (COND_EXPR, decl, NULL_TREE, NULL_TREE));
  2363.     default:
  2364.       assert (0 <= nonwrapper && nonwrapper <= 2);
  2365.     }
  2366.     }
  2367.   return error_mark_node;
  2368. }
  2369.  
  2370. /* Return an IDENTIFIER which can be used as a name for
  2371.    anonymous structs and unions.  */
  2372. tree
  2373. make_anon_name ()
  2374. {
  2375.   static int cnt = 0;
  2376.   char buf[32];
  2377.  
  2378.   sprintf (buf, ANON_AGGRNAME_FORMAT, cnt++);
  2379.   return get_identifier (buf);
  2380. }
  2381.  
  2382. /* Given an object OF, and a type conversion operator COMPONENT
  2383.    build a call to the conversion operator, if a call is requested,
  2384.    or return the address (as a pointer to member function) if one is not.
  2385.  
  2386.    OF can be a TYPE_DECL or any kind of datum that would normally
  2387.    be passed to `build_component_ref'.  It may also be NULL_TREE,
  2388.    in which case `current_class_type' and `current_class_decl'
  2389.    provide default values.
  2390.  
  2391.    BASETYPE_PATH, if non-null, is the path of basetypes
  2392.    to go through before we get the the instance of interest.
  2393.  
  2394.    PROTECT says whether we apply C++ scoping rules or not.  */
  2395. tree
  2396. build_component_type_expr (of, component, basetype_path, protect)
  2397.      tree of, component, basetype_path;
  2398.      int protect;
  2399. {
  2400.   tree cname = NULL_TREE;
  2401.   tree tmp, last;
  2402.   tree name;
  2403.   int flags = protect ? LOOKUP_NORMAL : LOOKUP_COMPLAIN;
  2404.  
  2405.   assert (IS_AGGR_TYPE (TREE_TYPE (of)));
  2406.   assert (TREE_CODE (component) == TYPE_EXPR);
  2407.  
  2408.   tmp = TREE_OPERAND (component, 0);
  2409.   last = NULL_TREE;
  2410.  
  2411.   while (tmp)
  2412.     {
  2413.       switch (TREE_CODE (tmp))
  2414.     {
  2415.     case CALL_EXPR:
  2416.       if (last)
  2417.         TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0);
  2418.       else
  2419.         TREE_OPERAND (component, 0) = TREE_OPERAND (tmp, 0);
  2420.       if (TREE_OPERAND (tmp, 0)
  2421.           && TREE_OPERAND (tmp, 0) != void_list_node)
  2422.         {
  2423.           error ("operator <typename> requires empty parameter list");
  2424.           TREE_OPERAND (tmp, 0) = NULL_TREE;
  2425.         }
  2426.       last = groktypename (build_tree_list (TREE_TYPE (component),
  2427.                         TREE_OPERAND (component, 0)));
  2428.       name = build_typename_overload (last);
  2429.       TREE_TYPE (name) = last;
  2430.  
  2431.       if (of && TREE_CODE (of) != TYPE_DECL)
  2432.         return build_method_call (of, name, NULL_TREE, NULL_TREE, flags);
  2433.       else if (of)
  2434.         {
  2435.           tree this_this;
  2436.  
  2437.           if (current_class_decl == NULL_TREE)
  2438.         {
  2439.           error ("object required for `operator <typename>' call");
  2440.           return error_mark_node;
  2441.         }
  2442.  
  2443.           this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl);
  2444.           return build_method_call (this_this, name, NULL_TREE,
  2445.                     NULL_TREE, flags | LOOKUP_NONVIRTUAL);
  2446.         }
  2447.       else if (current_class_decl)
  2448.         return build_method_call (tmp, name, NULL_TREE, NULL_TREE, flags);
  2449.  
  2450.       error ("object required for `operator <typename>' call");
  2451.       return error_mark_node;
  2452.  
  2453.     case INDIRECT_REF:
  2454.     case ADDR_EXPR:
  2455.     case ARRAY_REF:
  2456.       break;
  2457.  
  2458.     case SCOPE_REF:
  2459.       assert (cname == 0);
  2460.       cname = TREE_OPERAND (tmp, 0);
  2461.       tmp = TREE_OPERAND (tmp, 1);
  2462.       break;
  2463.  
  2464.     default:
  2465.       abort ();
  2466.     }
  2467.       last = tmp;
  2468.       tmp = TREE_OPERAND (tmp, 0);
  2469.     }
  2470.  
  2471.   last = groktypename (build_tree_list (TREE_TYPE (component), TREE_OPERAND (component, 0)));
  2472.   name = build_typename_overload (last);
  2473.   TREE_TYPE (name) = last;
  2474.   if (of && TREE_CODE (of) == TYPE_DECL)
  2475.     {
  2476.       if (cname == NULL_TREE)
  2477.     {
  2478.       cname = DECL_NAME (of);
  2479.       of = NULL_TREE;
  2480.     }
  2481.       else assert (cname == DECL_NAME (of));
  2482.     }
  2483.  
  2484.   if (of)
  2485.     {
  2486.       tree this_this;
  2487.  
  2488.       if (current_class_decl == NULL_TREE)
  2489.     {
  2490.       error ("object required for `operator <typename>' call");
  2491.       return error_mark_node;
  2492.     }
  2493.  
  2494.       this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl);
  2495.       return build_component_ref (this_this, name, 0, protect);
  2496.     }
  2497.   else if (cname)
  2498.     return build_offset_ref (cname, name);
  2499.   else if (current_class_name)
  2500.     return build_offset_ref (current_class_name, name);
  2501.  
  2502.   error ("object required for `operator <typename>' member reference");
  2503.   return error_mark_node;
  2504. }
  2505.